//
//  QQMusicDataTool.swift
//  JSQQMusic
//
//  Created by 马万里 on 2017/10/19.
//  Copyright © 2017年 马万里. All rights reserved.
//

import UIKit

class QQMusicDataTool: NSObject {
    
    class func getMusicMs(result: ([QQMusicModel]) -> ()) {
        
        // 解析歌曲信息
        
        // 1. 获取文件路径
        guard let path = Bundle.main.path(forResource: "Musics", ofType: "plist") else {
            result([QQMusicModel]())
            return
        }
        
        // 2. 获取文件内容
        guard let array = NSArray(contentsOfFile: path) else {
            result([QQMusicModel]())
            return
        }
        
        // 3. 解析，转换成歌曲类型
        var models = [QQMusicModel]()
        for dict in array {
            let model = QQMusicModel(dict: dict as! [String : Any])
            models.append(model)
        }
        result(models)
    }

}
